package com.stars.empoly.adapter

import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.util.SmartGlideImageLoader
import com.qmuiteam.qmui.kotlin.onClick
import com.stars.empoly.R
import com.stars.empoly.activity.*
import com.stars.empoly.databinding.ItemAddressListBinding
import com.stars.empoly.databinding.ItemHeartBinding
import com.stars.empoly.databinding.ItemMsgBinding
import com.stars.empoly.model.FollowList
import com.stars.empoly.model.MsgList
import com.stars.empoly.model.TrMsgList
import com.stars.empoly.vmodel.AddressListVModel
import com.stars.empoly.vmodel.HeartVModel
import com.stars.empoly.vmodel.MsgVModel
import com.trailer.base.base.BAdapter
import com.trailer.base.utils.B
import com.trailer.base.utils.UiSwitch

class HeartAdapter(var vm: HeartVModel) : BAdapter<FollowList, BaseDataBindingHolder<ItemHeartBinding>>(R.layout.item_heart) {

    override fun convert(holder: BaseDataBindingHolder<ItemHeartBinding>, item: FollowList) {
        holder.dataBinding?.vm = vm
        holder.dataBinding?.item = item
        holder.dataBinding?.position=holder.adapterPosition


        holder.dataBinding?.starView?.setScore(item.star.toFloat())
//        holder.dataBinding?.position = holder.adapterPosition

        holder.dataBinding?.imgLookLife?.onClick {
            //查看生活照

            var lifePhoto=item.lifePhoto
            if(null!=lifePhoto&&lifePhoto!=""){

                var s=lifePhoto
                var list=s!!.split(",")
                var path=mutableListOf<String>()
                for(item in list){
                    path.add(item)
                }
                XPopup.Builder(context)
                    .asImageViewer(
                        null, 0, list,
                        { popupView, position ->
                            popupView.updateSrcView( null)
                        }, SmartGlideImageLoader()
                    ).isShowSaveButton(false)
                    .show()

            }else{
                toast("没有生活照")
            }
        }



    }
}
